<template>
  <v-app class="no-scroll">
    <Layout></Layout>
  </v-app>
</template>

<script lang="ts" setup>
import Layout from './components/Layout.vue';
import { initSubscriptionsFromToken } from './composables/initSubscriptions';
import { useMessageStore } from './stores/app';
import { onMounted, watchEffect } from 'vue';

onMounted(async () => {
  console.log("已登录,注册订阅");
  const token = localStorage.getItem('jwt_token');
  if (token) {
    try {
      await initSubscriptionsFromToken(token);
      console.log('✅ 已登录用户，自动初始化订阅成功');
    } catch (err) {
      console.warn('⚠️ 自动初始化订阅失败', err);
    }
  }
});

let messageStore = useMessageStore();
watchEffect(() => {
  console.log('最新消息：', messageStore.messages);
});
</script>

<style scoped>

</style>
